//
//  comicChapterTableViewCell.m
//  动漫之家
//
//  Created by 王少泽 on 16/12/16.
//  Copyright © 2016年 王少泽. All rights reserved.
//

#import "comicChapterTableViewCell.h"
#import "ChapterCollectionViewCell.h"
#import "ComicReadViewController.h"

@implementation comicChapterTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.comicChapter.dataSource = self;
    self.comicChapter.delegate = self;
    
    UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(100, 58);
    flowLayout.minimumLineSpacing = 5.00;
    flowLayout.minimumInteritemSpacing = 5.00;
    //flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    [self.comicChapter setCollectionViewLayout:flowLayout];

    
    [self.comicChapter registerNib:[UINib nibWithNibName:@"ChapterCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"comicCell"];
    
    
    NSLog(@"cell里面的arr:%@",self.comicData);
   // [self.comicChapter registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"comicCell"];
    
    
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ChapterCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"comicCell" forIndexPath:indexPath];
    
    cell.titleText.text = @"hahahaha";
//    cell.titleText.text = [[self.comicData objectAtIndex:indexPath.row] objectForKey:@"name"];
    cell.titleText.textColor = [UIColor whiteColor];
    cell.titleText.backgroundColor = [UIColor redColor];
    //cell.backgroundColor = [UIColor redColor];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    ComicReadViewController* readPageVC = [[ComicReadViewController alloc]init];
    readPageVC.comicName = self.comicName;
    readPageVC.comicId = (int)[[self.comicData objectAtIndex:indexPath.row] objectForKey:@"id"];
    [self.readVC.navigationController pushViewController:[[ComicReadViewController alloc]init] animated:NO];
}

/*
 
 如果需要设置CollectionView的头部视图需要设置下面这个属性
 
 */
//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
//{
//    return CGSizeMake(80, 20);
//}

//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
//{
//    return 1;
//}
//
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
//{
//    return 1;
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
